<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/dualListbox/bootstrap-duallistbox.min.css}" rel="stylesheet"/>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<div class="container-div" style="margin-top: 10px;">
			<div class="col-sm-12 " >
				<table class="table table-bordered">
	               <thead>
		                <tr>
		                	<th>渠道编号</th>
		                    <th>目标机构编号</th>
		                    <th>操作</th>
		                </tr>
	                </thead>
	                <tbody>
		                <tr th:each="s,iterStat : ${targetInstRelationList}" >
		                    <td th:text="${s.fundChannelCode}"></td>
		                    <td th:text="${s.targetInstCode}"></td>
		                    <td><a class="btn btn-danger btn-xs" href="#" th:onclick="'javascript:removeTargetInstRelation('+${s.id}+');'">删除</a></td>
		                </tr>
	                </tbody>
	            </table>
			</div>
	    </div>
		
    	
        <form class="form-horizontal m" id="form-trFcTargetInstRelation-add">
        	<input id="fundChannelCode" name="fundChannelCode" th:value="${fundChannelCode}"  type="hidden">
             <div class="form-group">	
				<label class="col-sm-3 control-label">资金渠道名称：</label>
				<div class="col-sm-8">
					<input disabled="disabled" id="fundChannelName" name="fundChannelName" th:value="${fundChannelName}"  class="form-control" type="text">
				</div>
			</div>
             <div class="row">
                <div class="col-lg-12">
                    <div class="ibox-content">
                        <form id="form" action="#" class="wizard-big">
                            <select id="targetInstCode" name="targetInstCode" class="form-control dual_select" multiple>
                                <option th:each="fctin:${instList}" th:value="${fctin.targetInstCode}" th:text="${fctin.targetInstName}"></option>
                            </select>
                        </form>
                    </div>
                </div>
            </div>
            
            
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script th:src="@{/ajax/libs/dualListbox/jquery.bootstrap-duallistbox.js}"></script>
    <script type="text/javascript">
	    $(document).ready(function(){
	    	$('.dual_select').bootstrapDualListbox({
	        	selectorMinimalHeight: 160
	    	});
	    })
    	
		var prefix = ctx + "paychannel/trFcTargetInstRelation"
		$("#form-trFcTargetInstRelation-add").validate({
			rules:{
				targetInstCode:{
					required:true,
				}
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-trFcTargetInstRelation-add').serialize());
	        }
	    }
		
		function removeTargetInstRelation(id){
			$.modal.confirm("确定删除该条信息吗？", function() {
            	var data = { "ids": id };
            	$.operate.submit(prefix + "/remove", "post", "json", data);
            	window.location.reload();
        	});
		}
	</script>
</body>
</html>
